Mule : Http Redirection
This page last changed on Oct 19, 2006 by ross.
In order to redirect an http client, we need to set two properties on the endpoint. Firstly we need to set the 'http.status' property to something like 307, which instructs the client that the resource has be temporarily redirected. Check out the Http protocol for detailed information about these status values at http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html. The next property we need to set is the 'Location', which will point to where your client is going to be redirected. The following is an example of a service, which is listening on the local address http://localhost:8080/mineand will process the request, and then send a response with the redirection code, instructing the client to go to http://mule.mulesource.org/. <mule-descriptor name="httpListener" implementation="org.mule.components.simple.BridgeComponent"> <inbound-router> <endpoint address="http://localhost:8080/mine" synchronous="true"> <properties> <property name="http.status" value="307"/> <property name="Location" value="http://mule.mulesource.org/"/> </properties> </endpoint> </inbound-router> </mule-descriptor> One should note the synchronous attribute on the endpoint being set to true. If this is not set, the service will be asynchronous, thus once the request has been received on the endpoint, it will be placed inside an internal queue and a reply is immediately sent back. Then your service will dequeue the request at its own time, but will not be able to reply back to the client, since a reply has already been sent. By setting the synchronous attribute to true, the request will be directed to your service, and the reply being sent back will be the returned object from your service. |
Document generated by Confluence on Nov 27, 2006 10:27 |